from common.base_view import response_json
from common.const import *
from common.lib_mysql import News


class Booms(News):

    def __init__(self):
        super().__init__()
        self.table = "users_boom"

    def list(self, page, search_key, status):
        where_sql = list()
        search_sql = 'title like "%{}%".format(search_key)'
        if search_key:
            where_sql.append(search_sql)
        if status:
            where_sql.append("status = {}".format(status))
        return self.list_func_with_all(self.table, page, where_sql, "booms")

    def delete(self, ids):
        return self.delete_func(self.table, ids)

    def update(self, ids, up_dict):
        return self.update_by_id_func(self.table, ids, up_dict)

    def insert(self, insert_dict):
        return self.insert_func(self.table, insert_dict)
